import requests
import json
import base64
import urllib
from selenium import webdriver
import time
import requests
import scrapy

# class Getcookie(scrapy.Spider):
    #selenuim 访问 elements.envato.com

    # driver = webdriver.Chrome()
    # driver.get('https://elements.envato.com/')
    # time.sleep(1)

    # cookie = driver.get_cookies()
    # print(cookie)
    # jsonCookies = json.dumps(cookie)
    # with open('elements.json', 'w') as f:
    #     f.write(jsonCookies)


    # 调用cookie
    # str=''
    # with open('elements.json','r',encoding='utf-8') as f:
    #     listCookies=json.loads(f.read())
    # cookie = [item["name"] + "=" + item["value"] for item in listCookies]
    # cookiestr = '; '.join(item for item in cookie)
    # print(listCookies)


#     #找每一条cookie 并删除 ecpiry
#     for cookie in listCookies:
#         if 'expiry' in cookie:
#             del cookie['expiry']
    


# url='https://elements.envato.com/web-templates'
# headers={
#     'cookie':cookiestr,
#     'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'
# }
# html=requests.get(url=url,headers=headers)
# print(html.text)



